给整型二维数组 b[3][4]输入12个数据,计算并输出数组中所有正数之和、所有负数之和。
来源:百度知道 编辑:UC知道 时间:2024/09/28 14:22:27
C语言\C++都可
#include "stdio.h"
main()
{
int b[3][4],i,j,zh=0,fu=0;
printf("please input b[3][4]:\n");
for(i=0;i<3;i++)
for(j=0;j<4;j++)
{
scanf("%d",&b[i][j]);
if(b[i][j]>0)zh+=b[i][j];
if(b[i][j]<0)fu+=b[i][j];
}
printf("the sum of those numbers larger than 0 is : %d .\n",zh);
printf("the sum of those numbers smaller than 0 is : %d .",fu);
}
/*运行结果:
please input b[3][4]:
1 -2 3
-3 5 2
-3 -7 6
2 7 4
the sum of those numbers larger than 0 is : 30 .
the sum of those numbers smaller than 0 is : -15 .
*/
#include<cstdio>
using namespace std;
int b[3][4];
int main(){
int zheng_sum=0,fu_sum=0;
for(int i=0;i<3;++i)for(int j=0;j<4;++j){
scanf("%d",&b[i][j])
if(b[i][j]>0)zheng_sum+
给整型二维数组 b[3][4]输入12个数据,计算并输出数组中所有正数之和、所有负数之和。
通过键盘对一个3行4列的二维数组输入整型数值,并按表格形式输出此数组的所有元素
在C中能给一个二维数组这样赋值吗?b[2][3]={{1,2,3},{4,5,6}}
C语言----输入16个数据存放到二维整型数组a[4][4]中,输出最大值、最小值以及位置。
请教高手,用函数调换,使给定的一个3*3的二维整型数组转置,即行列互换,
输入一个3x6的二维整型数组,输出其中最大值、最小值用其所在的行列下标。
编程:输出二维3*4数组中的最大、最小值
二维数组
二维数组??
初学编程的一个小问题,各位大虾帮帮忙,整型二维数组怎么复制啊!